<?php
/**
 * Created by JetBrains PhpStorm.
 * User: anynix
 * Date: 12-8-5
 * Time: 下午3:00
 * To change this template use File | Settings | File Templates.
 */

class Book_m extends CI_Model{
    function __construct()
    {
        parent::__construct();
        $this->load->database();
    }

    function insert($book_data){
        $this->db->insert('book', $book_data);
    }

    function update($id, $book_data){
        $this->db->where('BOOK_ID', $id);
        $this->db->update('book', $book_data);
    }

    function remove($id){
        $this->db->where('BOOK_ID', $id);
        $this->db->delete('book');
    }

    function searchByBookname($name){
        $this->db->where('BOOK_NAME', $name);
        $this->db->select('*');
        $query = $this->db->get('book');
        return $query->result();
    }

    function searchByUserID($user_id){
        $this->db->where('USER_ID', $user_id);
        $this->db->select('*');
        $query = $this->db->get('book');
        return $query->result();
    }
}